package b3.config
{
	public class TownGridConfig extends BasicConfig
	{
		//格子类型
		public var type:int;
		//地表类型
		public var texture:int;
		//坐标
		public var posX:int;
		public var posY:int;
		//动物信息
		public var animalId:int;
		//方向
		public var direction:int;
		//用于计算路径, 距离
		public var dist:int;
		//用于计算路径, 路径父节点
		public var parent:TownGridConfig;
		//出口的目的地地址索引
		public var exitLiveId:int;
		//下一层索引
		public var exitLayerId:int;
		//锁索引
		public var keyId:int;
		//钥匙索引
		public var lockId:int;
		//宝箱宝物
		public var objectList:Object; 
		
		public function TownGridConfig(gridXML:XML = null)
		{
			if (gridXML != null)
			{
				type = parseInt(gridXML.type);
				texture = parseInt(gridXML.texture);
				posX = parseInt(gridXML.posX);
				posY = parseInt(gridXML.posY);
				animalId = parseInt(gridXML.animalId);
				direction = parseInt(gridXML.direction);
				exitLiveId = parseInt(gridXML.exitLiveId);
				exitLayerId = parseInt(gridXML.exitLayerId);
				keyId = parseInt(gridXML.keyId);
				lockId = parseInt(gridXML.lockId);
				if (gridXML.object.length() > 0)
				{
					objectList = new Object();
					for (var i:int = 0; i < gridXML.object.length(); i++)
					{
						var objectIndex:int = parseInt(gridXML.object[i].objectIndex);
						var objectNum:int = parseInt(gridXML.object[i].objectNum);
						var objectPossibility:Number = parseFloat(gridXML.object[i].objectPossibility);
						objectList[objectIndex] = [objectNum, objectPossibility];
					}
				}
			}
		}

	}
}